$(document).ready(function (event) {


    $.ajax({
        //IP定位
        url: "http://restapi.amap.com/v3/ip?key=c76df1373d9f8adca55f7f7bebae5f70",
        // https://restapi.amap.com/v3/geocode/geo?parameters
        success: function (result) {
            $(".postion").text(result.province + " " + result.city);
            $.ajax({
                url: "https://restapi.amap.com/v3/config/district?" + "keywords=" + "成都" + "&subdistrict=3&key=c76df1373d9f8adca55f7f7bebae5f70",
                dataType: "json",
                type: "get",
                success: function (province) {
                    //区级
                    $.each(province.districts, function (index, district) {
                        //县镇级
                        $.each(district.districts, function (index, county) {
                            $("#place").append(addCountyLi(county));

                            // $.each(county.districts,function (index,town) {
                            //
                            // })
                        })
                    })
                    //     console.log(data)
                }
            });
        }
    });
//
//     "<ul><li class='dropdown head-dpdn'>"
    function addCountyLi(currentProvincen) {
        return $("<li><a href='#'>" + currentProvincen.name + "</a></li>")
    }

    // function addTownUL() {
    //         return $("");
    // }
});


